<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <script src="./jquery.min.js"></script>
    <style>
      div {
        width: 100px;
        height: 100px;
        background-color: hotpink;
        display: none;
      }
    </style>
  </head>
  <body>
    <div></div>

    <button id="btn_slideDown">滑入</button>
    <button id="btn_slideUp">滑出</button>
    <button id="btn_slideToggle">切换</button>

    <script>
      $(function () {
        $('#btn_slideDown').on('click', function () {
          // 第二个参数表示动画曲线函数
          // linear：匀速
          $('div').slideDown(1000, 'linear', function () {
            console.log('动画执行完了之后的回调')
          })
        })
        $('#btn_slideUp').on('click', function () {
          // swing：两头慢，中间快
          $('div').slideUp(1000, 'swing')
        })
        $('#btn_slideToggle').on('click', function () {
          $('div').slideToggle()
        })
      })
    </script>
  </body>
</html>
